package com.thinkfit.jy.adapter;

import android.content.Context;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.common.lib.bean.VideoBean;
import com.common.lib.manager.DataManager;
import com.common.lib.utils.BaseUtils;
import com.thinkfit.jy.R;

import org.jetbrains.annotations.NotNull;

/**
 * 用户收藏视频记录
 */
public class CollectVideoAdapter extends BaseQuickAdapter<VideoBean, BaseViewHolder> {

    private Context mContext;
    private int mMainStyle;

    public CollectVideoAdapter(Context context) {
        super(R.layout.item_collect_video);
        mContext = context;
        mMainStyle = DataManager.Companion.getInstance().getMainStyle();
    }


    @Override
    protected void convert(@NotNull BaseViewHolder helper, VideoBean bean) {
        BaseUtils.StaticParams.loadImage(mContext, 0, bean.getCover(), helper.getView(R.id.iv));
        helper.setText(R.id.tvTitle, bean.getTitle())
                .setText(R.id.tv_level, getStrLevel(bean.getStar()))
                .setText(R.id.tv_video_time, mContext.getString(R.string.app_xx_minutes,bean.getLongtime()+""))
                .setText(R.id.tv_people_num, mContext.getString(R.string.app_sport_video_xx_browse,bean.getBrowse()+""));
    }

    public String getStrLevel(int level){
        String str = "";
        switch (level){
            case 1:
                str = mContext.getString(R.string.app_video_level_1);
                break;
            case 2:
                str = mContext.getString(R.string.app_video_level_2);
                break;
            case 3:
                str = mContext.getString(R.string.app_video_level_3);
                break;
            case 4:
                str = mContext.getString(R.string.app_video_level_4);
                break;
            case 5:
                str = mContext.getString(R.string.app_video_level_5);
                break;

        }
        return str;
    }
}
